home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Enlighten DSM 3.1
/
SGI EnlightenDSM 3.1.iso
/
DEC3240
/
COMMON.Z
/
COMMON
/
bin
/
set_nis_client
< prev
next >
Wrap
Text File
|
1999-04-16
|
2KB
|
111 lines
#!/bin/sh
#
# Copyright (c) 1990-1999 Enlighten Software Solutions, Inc.
#
# Check arguments: <domain> <master> <master IP> <start_at_boot>
if [ $# -ne 4 ]
then
exit 1
fi
DOMAIN=$1
MASTER=$2
MASTERIP=$3
STARTATBOOT=$4
# Initialize variables
TMP=/tmp/nissetup.client.$$
HOSTS=/etc/hosts
RCCONF=/etc/rc.config
ECHO=/bin/echo
RCMGR=/usr/sbin/rcmgr
NISSETUP=/usr/sbin/nissetup
# Check if NIS is already configured
prev_conf=`$RCMGR get NIS_CONF`
# Check to make sure nissetup won't complain about
# system configuration
if [ \! -w "$RCCONF" ]
then
exit 2
fi
hname=`hostname`
if [ $? -ne 0 ]
then
exit 3
fi
if [ "$prev_conf" = "YES" ]
then
exit 4
fi
# Yes, we want to continue
$ECHO "C" > $TMP
# Press ENTER twice
$ECHO "\n" >> $TMP
# The host's NIS domain name
$ECHO $DOMAIN >> $TMP
# ... yes, this is the correct NIS domain name
$ECHO "y" >> $TMP
# This is going to be a NIS client
$ECHO "3" >> $TMP
# Yes, we want to continue
$ECHO "C" >> $TMP
# Use the -s security option for ypbind
$ECHO "y" >> $TMP
# Use the -S security option for ypbind
$ECHO "y" >> $TMP
# Check to make sure the server name is a correct NIS server name
sed "s/#.*//" $HOSTS > $HOSTS.tmp
good=`egrep "[ ]$MASTER([ \.]|$)" $HOSTS.tmp`
if [ -n "$good" ]
then
short=`echo $hname | sed 's/\..*//'`
if [ "$MASTER" = "$hname" ] || [ "$MASTER" = "$short" ]
then
exit 5
fi
else
# add the entry to $HOSTS instead of exiting.
# we have the IP address in renldc already
# we'll assume the lookup on GUI host produces the right one! :)
echo "$MASTERIP $MASTER" >> $HOSTS
fi
# Enter (just one) authorized server
$ECHO $MASTER >> $TMP
$ECHO "" >> $TMP
# Yes, we want to continue
$ECHO "C" >> $TMP
# Disallow all ypset requests
$ECHO "3" >> $TMP
# ... yes, this is correct
$ECHO "y" >> $TMP
# Use all of the NIS databases served by the NIS server
$ECHO "y" >> $TMP
# Start the NIS daemons now
$ECHO "y" >> $TMP
# Run the NIS setup utility
cat $TMP | $NISSETUP
# Done!
rm $TMP
exit 0